#ifndef _SYS_RESOURCE_H_
#define _SYS_RESOURCE_H_

#include "common.h"

#define SAVE_TO_FILE_NAME "SAVE_NVME_"

//根据channel获取对应的写线程 id
#define GET_WRITE_THREAD_INDEX(channel) (channel % PCIE_WRITEFILES_THREAD_NUM)

//根据channel获取对应的文件 id 
#define GET_WRITE_FILE_INDEX(channel, threadId) ((channel - threadId)/PCIE_WRITEFILES_THREAD_NUM)

//根据channel获取对应的文件id
#define GET_FILE_INDEX(channel) GET_WRITE_FILE_INDEX(channel, GET_WRITE_THREAD_INDEX(channel))

//根据 channel 返回 其在 pwf 中存在的 cfile 
#define GET_PWF_FILE_INDEX(pwf,channel) ((pwf + GET_WRITE_THREAD_INDEX(channel))->filePro + GET_FILE_INDEX(channel)) 

#define ISTOP_NO                0
#define ISTOP_YES               1
#define ISEXIST_NO              0  
#define ISEXIST_YES             1  

PackWriteFile * apply_resource(int len, RecvCmd *recv_cmd, BQueueBox *qBox);
int free_resource(PackWriteFile *pwf, BQueueBox *qBox);

#endif
